unit uLog;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, cxGraphics, cxControls, cxLookAndFeels,
  cxLookAndFeelPainters, dxSkinsCore, dxSkinBlack, dxSkinBlue, dxSkinBlueprint,
  dxSkinCaramel, dxSkinCoffee, dxSkinDarkRoom, dxSkinDarkSide,
  dxSkinDevExpressDarkStyle, dxSkinDevExpressStyle, dxSkinFoggy,
  dxSkinGlassOceans, dxSkinHighContrast, dxSkiniMaginary, dxSkinLilian,
  dxSkinLiquidSky, dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMoneyTwins,
  dxSkinOffice2007Black, dxSkinOffice2007Blue, dxSkinOffice2007Green,
  dxSkinOffice2007Pink, dxSkinOffice2007Silver, dxSkinOffice2010Black,
  dxSkinOffice2010Blue, dxSkinOffice2010Silver, dxSkinPumpkin, dxSkinSeven,
  dxSkinSevenClassic, dxSkinSharp, dxSkinSharpPlus, dxSkinSilver,
  dxSkinSpringTime, dxSkinStardust, dxSkinSummer2008, dxSkinTheAsphaltWorld,
  dxSkinsDefaultPainters, dxSkinValentine, dxSkinVS2010, dxSkinWhiteprint,
  dxSkinXmas2008Blue, cxStyles, dxSkinscxPCPainter, cxCustomData, cxFilter,
  cxData, cxDataStorage, cxEdit, cxNavigator, Data.DB, cxDBData,
  cxGridCustomTableView, cxGridTableView, cxGridDBTableView, Datasnap.DBClient,
  ClientRowSet, cxGridLevel, cxClasses, cxGridCustomView, cxGrid,
  cxImageComboBox, cxMemo;

type
  TFrmShowLog = class(TForm)
    GrdBasic: TcxGrid;
    tvBasic: TcxGridDBTableView;
    lvEXP_COMP: TcxGridLevel;
    dsLog: TDataSource;
    crsLog: TClientRowSet;
    crsLogLOGID: TStringField;
    crsLogTABLENAME: TStringField;
    crsLogKEYFIELD: TStringField;
    crsLogKEYVALUE: TStringField;
    crsLogCONTENT: TStringField;
    crsLogLOGTIME: TDateTimeField;
    crsLogSYS_ACCOUNT: TStringField;
    crsLogUSERID: TStringField;
    crsLogACTIONNAME: TStringField;
    crsLogACTIONCAPTION: TStringField;
    crsLogUSERNAME: TStringField;
    crsLogEMPNO: TStringField;
    crsLogOPERATION: TStringField;
    crsLogIP_ADDRESS: TStringField;
    crsLogMAC_ADDRESS: TStringField;
    crsLogCREATE_DT: TStringField;
    crsLogGROUP_CODE: TStringField;
    crsLogOP_NODE: TStringField;
    tvBasicTABLENAME: TcxGridDBColumn;
    tvBasicKEYFIELD: TcxGridDBColumn;
    tvBasicKEYVALUE: TcxGridDBColumn;
    tvBasicCONTENT: TcxGridDBColumn;
    tvBasicLOGTIME: TcxGridDBColumn;
    tvBasicACTIONNAME: TcxGridDBColumn;
    tvBasicUSERNAME: TcxGridDBColumn;
    tvBasicEMPNO: TcxGridDBColumn;
    tvBasicOPERATION: TcxGridDBColumn;
    tvBasicOP_NODE: TcxGridDBColumn;
    procedure tvBasicCustomDrawIndicatorCell(Sender: TcxGridTableView;
      ACanvas: TcxCanvas; AViewInfo: TcxCustomGridIndicatorItemViewInfo;
      var ADone: Boolean);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FrmShowLog: TFrmShowLog;
  procedure FrmShowLogShow(crs:TClientRowSet);
implementation

{$R *.dfm}

uses BaseForm, ucommFunction;

procedure FrmShowLogShow(crs:TClientRowSet);
var
  sKey:string;
  iI:Integer;
begin
  Application.CreateForm(TFrmShowLog,FrmShowLog);
  for iI := 0 to crs.FieldCount-1 do
  begin
    if crs.Fields[iI].Tag=1 then
    begin
      sKey:=crs.Fields[iI].FieldName;
      Break;
    end;
  end;
  with FrmShowLog do
  begin
    crsLog.Close;
    crsLog.CommandText:='select t.* from sys_loginfo t where keyvalue='+QuotedStr(crs.FieldByName(sKey).AsString)+' and group_code='+QuotedStr(userInfo.groupCode)+' order by logtime desc';
    crsLog.Open;
    ShowModal;
    FreeAndNil(FrmShowLog);
  end;
end;

procedure TFrmShowLog.FormCreate(Sender: TObject);
begin
  pSetCaption(Self);
end;

procedure TFrmShowLog.tvBasicCustomDrawIndicatorCell(Sender: TcxGridTableView;
  ACanvas: TcxCanvas; AViewInfo: TcxCustomGridIndicatorItemViewInfo;
  var ADone: Boolean);
var
  FValue: string;
  FBounds: TRect;
begin
  if (AViewInfo is TcxGridIndicatorRowItemViewInfo) then
  begin
    FValue :=IntToStr(TcxGridIndicatorRowItemViewInfo(AViewInfo).GridRecord.Index+1);
    FBounds := AViewInfo.Bounds;
    ACanvas.FillRect(FBounds);
    ACanvas.DrawComplexFrame(FBounds, clBtnHighlight, clBtnShadow, [bBottom, bLeft, bRight], 1);
    InflateRect(FBounds, -1, -1);
    //ACanvas.Font.Color := clBlack;
    ACanvas.Brush.Style := bsClear;
    ACanvas.DrawText(FValue, FBounds, cxAlignCenter or cxAlignTop);
    ADone := True;
  end;
end;

end.
